package com.twb.core.base.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;

import com.twb.core.base.entity.BaseLoginUser;
import com.twb.core.security.TwbSecurityUtil;

@Validated
public class BaseController {

	@Autowired
	HttpServletRequest request;
	
	@Autowired
	HttpServletResponse response;

	@Autowired
	protected TwbSecurityUtil twbSecurityUtil;

	/**
	 * @Title  getLoginUser
	 * @Class: BaseController.java
	 * @Description 获取当登录人
	 * @param clazz
	 * @return
	 * @author DSY
	 * @date 2018年11月3日 下午8:23:10
	 */
	public <T extends BaseLoginUser> T getLoginUser() {
		return twbSecurityUtil.getLoginUser(request);
	}

	/**
	 * @Title  getRequest
	 * @Class: BaseController.java
	 * @Description 获取request对象
	 * @return
	 * @author DSY
	 * @date 2018年11月3日 下午8:25:12
	 */
	public HttpServletRequest getRequest() {
		return request;
	}

	/**
	 * @Title  getResponse
	 * @Class: BaseController.java
	 * @Description 获取response对象
	 * @return
	 * @author DSY
	 * @date 2018年11月3日 下午8:25:48
	 */
	public HttpServletResponse getResponse() {
		return response;
	}
}
